import config from "@/config"
import tool from '@/utils/tool';
import http from "@/utils/request"

export default {
	menu: {
		myMenus: {
//			url: `${config.API_URL}/system/menu/my/1.6.1`, //TODO ftquan
			url: `http://127.0.0.1:8000/menus/current`,
			name: "获取我的菜单",
			get: async function(){
				let token = tool.cookie.get("TOKEN");
				return await http.get(this.url, {access_token: token});
			}
		},
		list: {
//			url: `${config.API_URL}/system/menu/list`,  //TODO ftquan
			url: `http://127.0.0.1:8000/menus/tree`,
			name: "获取菜单",
			get: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		}
	},
	dic: {
		list: {
			url: `http://127.0.0.1:8000/dictDatas/list`,
			name: "字典明细",
			get: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		},
		get: {
			url: `${config.API_URL}/system/dic/get`,
			name: "获取字典数据",
			get: async function(params){
				return await http.get(this.url, params);
			}
		},
		save: {
			url: `http://127.0.0.1:8000/dictDatas/saveOrUpdate`,
			name: "保存字典",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.postJson(this.url, params);
			}
		},
		delete: {
			url: `http://127.0.0.1:8000/dictDatas/delete`,
			name: "删除字典",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.post(this.url, params);
			}
		},
	},
	dicType: {
		list: {
//			url: `${config.API_URL}/system/dic/tree`,
			url: `http://127.0.0.1:8000/dicts`,
			name: "获取字典分类",
			get: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		},
		save: {
			url: `http://127.0.0.1:8000/dicts/saveOrUpdate`,
			name: "保存字典分类",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.postJson(this.url, params);
			}
		},
		delete: {
			url: `http://127.0.0.1:8000/dicts/delete`,
			name: "删除字典分类",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.post(this.url, params);
			}
		},
	},
	role: {
		list: {
			url: `http://127.0.0.1:8000/roles`,
			name: "获取角色列表",
			get: async function(params){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		},
		save: {
			url: `http://127.0.0.1:8000/roles/saveOrUpdate`,
			name: "保存角色",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.postJson(this.url, params);
			}
		},
	},
	company: {
		list: {
			url: `http://127.0.0.1:8000/companys`,
			name: "获取公司列表",
			get: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		},
		save: {
			url: `http://127.0.0.1:8000/companys/saveOrUpdate`,
			name: "保存公司",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.postJson(this.url, params);
			}
		},
		delete: {
			url: `http://127.0.0.1:8000/companys/delete`,
			name: "删除公司",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.post(this.url, params);
			}
		}
	},
	dept: {
		list: {
//			url: `${config.API_URL}/system/dept/list`,
			url: `http://127.0.0.1:8000/departments`,
			name: "获取部门列表",
			get: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		},
		tree: {
			url: `http://127.0.0.1:8000/orgs/tree`,
			name: "获取部门树",
			get: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		},
		save: {
			url: `http://127.0.0.1:8000/departments/saveOrUpdate`,
			name: "保存部门",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.postJson(this.url, params);
			}
		},
		delete: {
			url: `http://127.0.0.1:8000/departments/delete`,
			name: "删除部门",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.post(this.url, params);
			}
		}
	},
	user: {
		list: {
			url: `http://127.0.0.1:8000/users`,
			name: "获取用户列表",
			get: async function(params){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		},
		roles: {
			url: `http://127.0.0.1:8000/users/roles`,
			name: "获取用户角色",
			get: async function(params){
				let token = tool.cookie.get("TOKEN");
				params.access_token = token;
				return await http.get(this.url, params);
			}
		},
		save: {
			url: `http://127.0.0.1:8000/users/saveOrUpdate`,
			name: "保存用户",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.postJson(this.url, params);
			}
		},
		delete: {
			url: `http://127.0.0.1:8000/users/delete`,
			name: "删除用户",
			post: async function(params={}){
				let token = tool.cookie.get("TOKEN");
				this.url = (this.url.indexOf('?')>0? this.url.substring(0,this.url.indexOf('?')):this.url) + "?access_token=" + token;
				return await http.post(this.url, params);
			}
		}
	},
	app: {
		list: {
			url: `${config.API_URL}/system/app/list`,
			name: "应用列表",
			get: async function(){
				return await http.get(this.url);
			}
		}
	},
	log: {
		list: {
			url: `${config.API_URL}/system/log/list`,
			name: "日志列表",
			get: async function(params){
				return await http.get(this.url, params);
			}
		}
	},
	table: {
		list: {
			url: `${config.API_URL}/system/table/list`,
			name: "表格列管理列表",
			get: async function(params){
				return await http.get(this.url, params);
			}
		},
		info: {
			url: `${config.API_URL}/system/table/info`,
			name: "表格列管理详情",
			get: async function(params){
				return await http.get(this.url, params);
			}
		}
	},
	tasks: {
		list: {
			url: `${config.API_URL}/system/tasks/list`,
			name: "系统任务管理",
			get: async function(params){
				return await http.get(this.url, params);
			}
		}
	}
}
